/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

//网点公众号管理
import { Request, Response } from 'express';
import { ResponseItem, responseSuccess } from './utils';
import type { Kbdby } from '@/pages/NetworkWxmini/index.d';
import Mock from 'mockjs';

export default {
  'POST /shopOpen/ajax': (req: Request, res: Response, u: string) => {
    let { action } = req.body;
    let data: any = [];
    const authOfficialAccountsList: Kbdby[] = Mock.mock({
      'list|30': [
        {
          'id|+1': 1,
          account: '12345678990@qq.com',
          app_name: 'minipost_1033',
          app_platform: 'weixin_mini',
          app_label: '通递驿站',
          app_id: 'wx123123123123',
          auth_app_id: 'auth_app_id22222',
          app_secret: 'secret123123123',
          user_info: {
            name: '张三',
            phone: '13783636924',
          },
          is_franchisee: '1',
          franchisee_info: '荣昌快宝加盟商 13783636923',
          version_type: 'C',
          auth_time: Mock.Random.datetime('yyyy-MM-dd A HH:mm:ss'),
          auth_cancel_time: Mock.Random.datetime('yyyy-MM-dd A HH:mm:ss'),
          'is_close|1': true,
          islevel: '2',
          'platform|0-1': 1,
          is_newbest: '2',
          is_audit: '2',
          is_company: '0',
          is_interflow: '0',
          'current_version|1-3': 3,
          version_code: '222',
          is_history: '0',
          level: '2',
          type: '插件版',
        },
      ],
      count: '30',
    });
    const authInfo: Kbdby[] = Mock.mock({
      'id|+1': 1,
      'cloud_print|1-5': 5,
      'default_agent_guid|1-10000000': 10000000,
      'default_dak_id|1-1000000000': 1000000000,
      'default_courier_id|1-1000000000': 1000000000,
      welcome: '欢迎你',
      'dak_id|1-1000000000': 1000000000,
      tbk_title: '测试标题',
      tbk_url: 'https://',
      tbk_content: '23aaaaa',
      coupon: 1233,
      merchant_entry: '222',
      local_mall: '222',
      urgent_delivery: '222',
      nick_name: '嘚叻',
      platform: 'gzh_platform',
      auth_time: '2020-02-02',
      'auth_cancel_time｜0-1': 1 ? '2020-02-02' : '',
    });
    const miniInfo: Kbdby[] = Mock.mock({
      id: '123123213',
      account: '12345678990@qq.com',
      password: '123',
      app_name: 'minipost_1032',
      app_label: '平台名称',
      app_account: '平台英文名称',
      app_id: 'wxb09d66967aa2c2d3',
      app_secret: '123123',
      level: '2',
      type: '快递版',
      is_delete: '0',
      create_time: '2021-01-10 00:00:00',
      update_time: '2021-12-17 15:23:47',
      user_info: '原嘉琦 17606137848',
      is_franchisee: '1',
      franchisee_info: '',
      over_time: '',
    });

    const addManager = Mock.mock({
      list: {
        content: 'http://weixin.qq.com/q/02ackocltJeDi1NqK4hx1q',
        sceneId: 390784601,
        url:
          'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQFO7zwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyYWNrb2NsdEplRGkxTnFLNGh4MXEAAgQ6EsRhAwQgHAAA',
      },
    });

    const getManagerList = Mock.mock({
      'list|3': [
        {
          create_time: '2018-08-09 10:29:36',
          'id|1-1000': 1000,
          is_delete: '0',
          is_root: '0',
          iu_id: '2044981',
          nickname: '王现勇',
          open_platform: 'wt_mini_55',
          platform: 'weixin_shop_36',
          platform_type: 'weixin_mini',
          u_note: '王现勇',
          uid: 'o3S2n0oO7X1mNv2AE1XdChUQQBwQ',
          update_time: '2021-05-18 11:23:59',
        },
      ],
    });

    const getAdInfo = Mock.mock({
      'list|3': [
        {
          ad_id: 'aa',
          create_time: '2021-12-27 11:09:09',
          'id|1-1000': 1000,
          is_delete: '0',
          name: '1',
          platform: 'minipost_1002',
          update_time: '2021-12-27 11:09:09',
        },
      ],
    });

    if (action == 'authOfficialAccountsList') {
      data = authOfficialAccountsList;
    } else if (action == 'authInfo' || action == 'authOfficialAccountsGet') {
      data = authInfo;
    } else if (action == 'miniInfo') {
      data = miniInfo;
    } else if (action == 'addManager') {
      data = addManager;
    } else if (action == 'getManagerList') {
      data = getManagerList;
    } else if (action == 'getAdInfo' || action == 'getAdInfoList') {
      data = getAdInfo;
      if (req.body.id) {
        data = getAdInfo.list[0];
      }
    }
    const result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: data,
    };
    return res.json(result);
  },

  'POST /WeiXinMpCustom/ajax': (req: Request, res: Response) => {
    return res.json({
      code: 0,
      msg: '成功',
      data: {},
    });
  },
};
